package com.tzy.shop.config;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * web相关的配置类
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 添加静态资源处理程序 / 静态资源处理映射
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
//        图片放在resource/static/下面
//        访问直接ip:端口/图片名称.后缀 //示例: http://localhost:8082/api/assets/1.jpg
//        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        //static目录下要有assets文件夹
        registry.addResourceHandler("/assets/**").addResourceLocations("file:D:/upload/");
        WebMvcConfigurer.super.addResourceHandlers(registry);
    }
}
